package com.xbongbong.paas.print.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import lombok.Getter;

/**
 * 额外需要打印的字段
 * @author zheng.li
 * @version v1.0
 * @date 2019/3/5 15:30
 * @since v1.0
 */
@Getter
public enum AdditionalPrintAttrEnum {
    /**
     * 客户地址
     */
    CUSTOMER_ADDRESS("customerAddress","enum.additionalPrintAttr.name.customer_address","customerAddress",XbbRefTypeEnum.CUSTOMER.getCode()),
    /**
     * 客户电话
     */
    CUSTOMER_PHONE("customerPhone","enum.additionalPrintAttr.name.customer_phone","customerPhone",XbbRefTypeEnum.CUSTOMER.getCode()),
    /**
     * 联系人电话
     */
    CONTACT_PHONE("contactPhone","enum.additionalPrintAttr.name.contact_phone","contactPhone",XbbRefTypeEnum.CONTACT.getCode()),
    /**
     * 联系人电话
     */
    CONTACT_ADDRESS("contactAddress","enum.additionalPrintAttr.name.contact_address","contactAddress",XbbRefTypeEnum.CONTACT.getCode()),
    /**
     * 供应商联系人
     */
    SUPPLIER_CONTACT_NAME("supplierContactName", "enum.additionalPrintAttr.name.supplier_contact_name","supplierContactName",XbbRefTypeEnum.SUPPLIER_CONTACT.getCode()),
    SUPPLIER_PHONE("supplierPhone", "enum.additionalPrintAttr.name.supplier_phone","supplierPhone", XbbRefTypeEnum.SUPPLIER.getCode()),
    SUPPLIER_ADDRESS("supplierAddress", "enum.additionalPrintAttr.name.supplier_address", "supplierAddress",XbbRefTypeEnum.SUPPLIER.getCode()),
    SUPPLIER_MANAGER_NAME("supplierManagerName", "enum.additionalPrintAttr.name.supplier_manager_name","supplierManagerName", XbbRefTypeEnum.SUPPLIER.getCode()),
    SUPPLIER_CONTACT_PHONE("supplierContactPhone", "enum.additionalPrintAttr.name.supplier_contact_phone","supplierContactPhone",XbbRefTypeEnum.SUPPLIER_CONTACT.getCode()),
    /**
     * 退货状态
     */
    STATUS_STR("statusStr", "enum.additionalPrintAttr.name.status_str", "statusStr",XbbRefTypeEnum.RETURNED_PURCHASE.getCode()),
    /**
     * 供应商
     */
    SUPPLIER("supplier", "enum.additionalPrintAttr.name.supplier","supplier", XbbRefTypeEnum.SUPPLIER.getCode()),
    /**
     * 客户名称
     */
    CUSTOMER("customer","enum.additionalPrintAttr.name.customer","customer",XbbRefTypeEnum.CUSTOMER.getCode()),
    /**
     *  调入仓库地址
     */
    IN_ADDRESS("inAddress", "enum.additionalPrintAttr.name.in_address","inAddress", XbbRefTypeEnum.TRANSFER.getCode()),
    IN_USER_NAME("inUserName", "enum.additionalPrintAttr.name.in_user_name","inUserName", XbbRefTypeEnum.TRANSFER.getCode()),
    OUT_ADDRESS("outAddress", "enum.additionalPrintAttr.name.out_address","outAddress", XbbRefTypeEnum.TRANSFER.getCode()),
    OUT_USER_NAME("outUserName", "enum.additionalPrintAttr.name.out_user_name","outUserName", XbbRefTypeEnum.TRANSFER.getCode()),
    /**
     * 负责人
     */
    MANAGER("manager", "enum.additionalPrintAttr.name.manager","manager",0),
    /**
     * 制表人
     */
    TABLE_MAKER("tableMaker", "enum.additionalPrintAttr.name.table_maker","tableMaker",0),
    /**
     * 打印日期
     */
    PRINT_DATE_TIME("printDateTime", "enum.additionalPrintAttr.name.print_date_time","printDateTime",0),
    /**
     * 生成对账单：回款类型
     */
    PAYMENT_TYPE("paymentType","enum.additionalPrintAttr.name.payment_type","paymentType",XbbRefTypeEnum.CUSTOMER_STATEMENT.getCode()),
    ;
    private String attr;
    private String name;
    private int businessType;
    private String saasAttr;

    AdditionalPrintAttrEnum(String attr, String name,String saasAttr,int businessType) {
        this.attr = attr;
        this.name = name;
        this.saasAttr = saasAttr;
        this.businessType = businessType;
    }


    public static AdditionalPrintAttrEnum getByAttr(String alias) {
        for (AdditionalPrintAttrEnum cacheCode : values()) {
            if (cacheCode.getAttr().equals(alias)) {
                return cacheCode;
            }
        }
        return null;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
}
